package com.aqie.rabbit.bean.api.base;

public class CodeMsg<T> {
    private int code;
    private String msg;


    private CodeMsg() {}

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }


    public CodeMsg(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }



    public CodeMsg fillArgs(Object... args) {
        int code = this.code;
        String message = String.format(this.msg, args);
        return new CodeMsg(code, message);
    }

    // 通用异常 5001XX
    public static CodeMsg SERVER_ERROR = new CodeMsg(500100, "服务端异常");
    public static CodeMsg PARAMETER_ERROR = new CodeMsg(500101, "参数校验异常：%s");
    public static CodeMsg REQUEST_ILLEGAL = new CodeMsg(500102, "请求非法");
    public static CodeMsg ACCESS_LIMIT_REACHED = new CodeMsg(500103, "访问太频繁！");
    public static CodeMsg SMS_SERVER_ERROR = new CodeMsg(500104, "短信服务繁忙");
    public static CodeMsg MEDIA_TYPE_NOT_ACCEPT_ERROR = new CodeMsg(500105, "媒体类型不支持");

    // 用户模块 5002XX
    public static CodeMsg USER_NAME_NOT_FOUND_ERROR = new CodeMsg(500200, "用户名不存在");
    public static CodeMsg USER_MOBILE_NOT_FOUND_ERROR = new CodeMsg(500201, "手机号不存在");
    public static CodeMsg USER_NOT_LOGIN_ERROR = new CodeMsg(500202, "用户尚未登录");
    public static CodeMsg USER_NAME_EXIST_ERROR = new CodeMsg(500203, "用户名已存在");
    public static CodeMsg USER_MOBILE_EXIT_ERROR = new CodeMsg(500204, "手机号已存在");
    public static CodeMsg USER_NAME_OR_PASSWORD_ERROR = new CodeMsg(500205, "用户名或密码错误");
    public static CodeMsg USER_ID_EXIST_ERROR = new CodeMsg(500206, "指定id用户不存在");
    public static CodeMsg SESSION_ERROR = new CodeMsg(500210, "Session不存在或者已经失效");
    public static CodeMsg TOKEN_INVALID_ERROR = new CodeMsg(500211, "令牌不存在或者已经失效");
    public static CodeMsg FOLLOW_YOURSELF_ERROR = new CodeMsg(500300, "不能关注自己");
    public static CodeMsg FOLLOW_USER_ID_NOT_EXIT_ERROR = new CodeMsg(500301, "关注的用户ID不存在");
    public static CodeMsg ALREADY_FOLLOW_ERROR = new CodeMsg(500302, "您已关注该用户");
    public static CodeMsg FOLLOW_USER_LIST_EMPTY_ERROR = new CodeMsg(500303, "关注用户列表为空");
    public static CodeMsg SEARCH_RESULT_EMPTY_ERROR = new CodeMsg(500304, "搜索结果为空");




    // 群 5003XX
    public static CodeMsg GROUP_NOT_FOUND_ERROR = new CodeMsg(500300, "群组不存在");
    public static CodeMsg GROUP_MEMBER_NOT_FOUND_ERROR  = new CodeMsg(500301, "群成员不存在");
    public static CodeMsg GROUP_NAME_EXIT_ERROR  = new CodeMsg(500302, "群名称已存在");
    public static CodeMsg GET_GROUP_CREATOR_ERROR  = new CodeMsg(500303, "创建群后 获取群创建者失败");
    public static CodeMsg GROUP_MEMBER_LIST_EMPTY_ERROR  = new CodeMsg(500304, "创建群 群成员列表为空");
    public static CodeMsg GROUP_NOT_JOIN_ERROR  = new CodeMsg(500305, "您尚未加入该群组");
    public static CodeMsg GROUP_ADD_MEMBER_LIST_EMPTY_ERROR  = new CodeMsg(500306, "添加群组 成员集合不能为空");
    public static CodeMsg GROUP_CREATE_MEMBER_LIST_EMPTY_ERROR  = new CodeMsg(500307, "创建群组 成员集合不能为空");
    public static CodeMsg GROUP_CREATE_MEMBER_LESS_THAN_TWO_ERROR  = new CodeMsg(500308, "创建群组时 成员少于两人");
    public static CodeMsg GROUP_ADD_MEMBER_LESS_THAN_TWO_ERROR  = new CodeMsg(500309, "添加群成员时 成员少于两人");
    public static CodeMsg GROUP_ADD_NOT_ADMINISTRATOR_ERROR  = new CodeMsg(500310, "添加群成员时 没有管理员权限");
    public static CodeMsg GROUP_ADD_NEW_MEMBER_LIST_EMPTY_ERROR  = new CodeMsg(500311, "添加群成员时 新增成员数为零");


    // 数据库 5004XX
    public static CodeMsg DATABASE_ERROR  = new CodeMsg(500400, "数据库异常");
    public static CodeMsg DATABASE_INTEGRITY_VIOLATION_ERROR  = new CodeMsg(500401, "数据完整性的异常 不符合约束条件");
    public static CodeMsg ACCOUNT_REGISTER_ERROR = new CodeMsg(500411, "账户注册失败");
    public static CodeMsg BIND_PUSH_ID_ERROR = new CodeMsg(500412, "绑定推送ID失败");
    public static CodeMsg USER_UPDATE_ERROR = new CodeMsg(500413, "用户更新失败");


    // 发送消息
    public static CodeMsg MESSAGE_SEND_TYPE__ERROR  = new CodeMsg(500600, "发送消息类型错误");
    public static CodeMsg RECEIVER_USER_ID_EXIST_ERROR = new CodeMsg(500601, "指定id 接收者不存在");
    public static CodeMsg CAN_NOT_SEND_TO_SELF_ERROR = new CodeMsg(500602, "不能发消息给自己");
    public static CodeMsg CAN_NOT_FIND_YOUR_GROUP_ERROR = new CodeMsg(500603, "不能找到该群, 有可能是你不是群的成员");
    public static CodeMsg MESSAGE_SAVE_DATABASE_ERROR = new CodeMsg(500604, "消息存储数据库错误");
    public static CodeMsg MESSAGE_AND_SENDER_IS_NULL_ERROR = new CodeMsg(500605, "发送者 和 消息不能为空");
    public static CodeMsg MESSAGE_RECEIVER_ID_IS_NULL_ERROR = new CodeMsg(500606, "消息体中接收者id不能为空");
    public static CodeMsg GROUP_IS_EMPTY_ERROR = new CodeMsg(500607, "群成员为空");
    public static CodeMsg GROUP_ONLY_HAVE_YOURSELF_ERROR = new CodeMsg(500608, "群成员只有你 加点群成员再发消息吧");
    public static CodeMsg GROUP_MEMBER_HAVE_NOT_USER_ERROR = new CodeMsg(500609, "群成员中用户信息为空");

    // 服务器异常
    public static CodeMsg REDIS_CONNECT_ERROR  = new CodeMsg(5007601, "reids 连接异常");
    public static CodeMsg MYSQL_CONNECT_ERROR  = new CodeMsg(5007602, "mysql 连接异常");
    public static CodeMsg MYSQL_DATA_ACCESS_RESOURCE_FAILURE_ERROR  = new CodeMsg(5007603, "客户端未检测到服务器释放连接池连接");
    public static CodeMsg CREATE_GROUP_ERROR  = new CodeMsg(5007611, "创建群组错误");
    public static CodeMsg ADD_GROUP_MEMBER_ERROR  = new CodeMsg(5007612, "添加群成员错误");
    public static CodeMsg GET_GROUP_MEMBER_ERROR  = new CodeMsg(5007613, "获取群成员错误");

}
